<?php

namespace App\V3\V3_1\Controllers;

use App\V3\V3_1\Models\RegionModel;
use \App\Http\Controllers\Api\BaseController;

class RegionController extends BaseController
{

    public function list()
    {
        $province = RegionModel::select(
            'id', 'name'
        )
            ->with('city', function($query) {
                $query->select('id', 'name', 'parent_id')->where('level', 2)->orderBy('sort', 'ASC');
            })
        ->where('level', 1)->orderBy('sort', 'ASC')->get()->toArray();
        return $this->success($province);
    }
}
